package experiment_6;

import java.io.*;

public class IO_document {
    public static void xieRu(String str, String dizhi) {
        FileWriter writer;
        try {
            writer = new FileWriter("E:\\FirstJava\\src\\experiment_6\\" + dizhi + ".txt");
            writer.write(str);
            writer.flush();//
            writer.close();
        } catch (Exception e) {
            System.out.println("有错误");
        }
    }

    public static void duQu(String dizhi) throws Exception {
        FileReader fileReader = new FileReader(dizhi);
        int length = 0;
        String str = "";
        while ((length = fileReader.read()) != -1) {
            // System.out.print((char)length);
            str += (char) length;
        }
        System.out.println(str);
        fileReader.close();
    }

    public static String zhuanHuan(String[][] arr) {
        String str = "";
        for (int k = 0; k < arr[0].length; k++) {
            for (int i = 0; i < arr.length; i++) {
                if (i == arr.length - 1) {
                    str += arr[i][k] + "\n";
                } else {
                    str += arr[i][k] + "\t";
                }
            }
        }
        return str;
    }

    public static void delete_txt(String fileName) {
        File file = new File(fileName);
        try {
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileWriter = new FileWriter(file);
            fileWriter.write("");
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws Exception {
        delete_txt("E:\\FirstJava\\src\\experiment_6\\选课.txt");
    }

}